<%--
  Created by IntelliJ IDEA.
  User: 周帅航
  Date: 2020/8/19 0019
  Time: 23:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8">
    <title>
        后台管理系统
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../css/x-admin.css" media="all">
</head>

<body>
<div class="x-body">
    <form class="layui-form" action="../book/add" method="post" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label for="bookId" class="layui-form-label">
                <span class="x-red">*</span>书籍ID
            </label>
            <div class="layui-input-inline">
                <input type="text" id="bookId" name="bookId" required="" lay-verify="required"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="bookName" class="layui-form-label">
                <span class="x-red">*</span>书名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="bookName" name="bookName" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="bookAuthor" class="layui-form-label">
                <span class="x-red">*</span>作者
            </label>
            <div class="layui-input-inline">
                <input type="text" id="bookAuthor" name="bookAuthor" required="" lay-verify="phone"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="bookPress" class="layui-form-label">
                <span class="x-red">*</span>出版社
            </label>
            <div class="layui-input-inline">
                <input type="text" id="bookPress" name="bookPress" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="isbn" class="layui-form-label">
                <span class="x-red">*</span>ISBN
            </label>
            <div class="layui-input-inline">
                <input type="text" id="isbn" name="isbn" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="publishDate" class="layui-form-label">
                <span class="x-red">*</span>出版日期
            </label>
            <div class="layui-input-inline">
                <input type="date" id="publishDate" name="publishDate" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="img" class="layui-form-label">
                <span class="x-red">*</span>图片
            </label>
            <div class="layui-input-inline">
                <input type="text" id="img" name="img" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
                <input type="file" name="images">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="description" class="layui-form-label">
                <span class="x-red">*</span>简介
            </label>
            <div class="layui-input-inline">
                <textarea placeholder="请输入内容" id="description" name="description" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="pages" class="layui-form-label">
                <span class="x-red">*</span>页数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="pages" name="pages" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="typeId" class="layui-form-label">
                <span class="x-red">*</span>ISBN
            </label>
            <div class="layui-input-inline">
                <select id="typeId" name="typeId" class="valid">
                    <option value="1">人文社科</option>
                    <option value="2">文学艺术</option>
                    <option value="3">经管法律</option>
                    <option value="4">少儿图书</option>
                    <option value="5">科学技术</option>
                    <option value="6">电脑网络</option>
                    <option value="7">生活时尚</option>
                    <option value="8">教育教材</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="price" class="layui-form-label">
                <span class="x-red">*</span>原价
            </label>
            <div class="layui-input-inline">
                <input type="text" id="price" name="price" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="discount" class="layui-form-label">
                <span class="x-red">*</span>折扣
            </label>
            <div class="layui-input-inline">
                <input type="text" id="discount" name="discount" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="stock" class="layui-form-label">
                <span class="x-red">*</span>库存
            </label>
            <div class="layui-input-inline">
                <input type="text" id="stock" name="stock" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <button  class="layui-btn" lay-filter="add" type="submit">
                增加
            </button>
        </div>
</form>
</div>
<script src="../lib/layui/layui.js" charset="utf-8">
</script>
<script src="../js/x-layui.js" charset="utf-8">
</script>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form()
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            nikename: function(value){
                if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
            ,pass: [/(.+){3,8}$/, '密码必须3到8位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
        });

        //监听提交
        form.on('submit(add)', function(data){
            console.log(data);
            //发异步，把数据提交给php
            layer.alert("增加成功", {icon: 6},function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
            return false;
        });
    });
</script>

</body>
</html>
